﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ras2Logic;

namespace Ras2Win
{
    /// <summary>
    /// Aðal klasinn sem inniheldur aðalformið.
    /// </summary>
    public partial class Ras2MainForm : Form
    {
        #region Member breytur

        #endregion

        #region Smiðir

        /// <summary>
        /// Færibreytulaus smiður
        /// </summary>
        public Ras2MainForm()
        {
            InitializeComponent();
        }

        #endregion

        #region Get / Set föll

        #endregion

        #region Private föll

        /// <summary>
        /// Fall sem lokar forritinu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_btnQuit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        /// <summary>
        /// Fall sem kallar í rétt editfall í viðkomandi viewi eftir því hvaða tab er valið á aðalforminu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_btnEdit_Click(object sender, EventArgs e)
        {
            if (m_tabControl.SelectedTab == m_tabHitLists)
            {
                //Opna edit fyrir valinn vinsældarlista
                m_hitListView.OnEditClick();
            }
            else if (m_tabControl.SelectedTab == m_tabSongs)
            {
                //Opna edit fyrir valið lag
                m_songView.OnEditClick();
            }
            else if (m_tabControl.SelectedTab == m_tabPerformers)
            {
                //Opna edit fyrir valinn flytjanda
                m_performerView.OnEditClick();
            }
        }

        /// <summary>
        /// Fall sem skiptir um texta á nýskrá takkanum eftir því hvaða tab er valið.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_tabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Breyta texta á takka.
            if (m_tabControl.SelectedTab == m_tabHitLists)
            {
                m_btnNewEntry.Text = "Nýjan lista";
            }
            else if (m_tabControl.SelectedTab == m_tabSongs)
            {
                m_btnNewEntry.Text = "Nýtt lag";
            }
            else if (m_tabControl.SelectedTab == m_tabPerformers)
            {
                m_btnNewEntry.Text = "Nýjan flytjanda";
            }
        }

        /// <summary>
        /// Fall sem velur rétt new click fall í viewinu eftir því hvaða tab er valið.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_btnNewEntry_Click(object sender, EventArgs e)
        {
            if (m_tabControl.SelectedTab == m_tabHitLists)
            {
                //Opna editglugga fyrir valinn vinsældarlista
                m_hitListView.OnNewClick();
            }
            else if (m_tabControl.SelectedTab == m_tabSongs)
            {
                //Opna editglugga fyrir valið lag
                m_songView.OnNewClick();
            }
            else if (m_tabControl.SelectedTab == m_tabPerformers)
            {
                //Opna editglugga fyrir valinn flytjanda
                m_performerView.OnNewClick();
            }
        }

        #endregion

        #region Public föll

        #endregion
    }
}
